const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');

let pathsToClean = [
	'dist',
]

module.exports = {
	mode: "none",
	entry: "./src/main.tsx",
	output: {
		filename: "[name].[hash:4].bundle.js",
		path: path.resolve(__dirname, 'dist')
	},

	devtool: "inline-source-map",
	devServer: {
		contentBase: './dist',
		hot: true,
	},
	resolve: {
		extensions: [".ts", ".tsx", ".js", ".json"]
	},
	module: {
		rules: [
			{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
			{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
		]
	},
	// externals: {
	// 	"react": "React",
	// 	"react-dom": "ReactDOM"
	// },
	plugins: [
		new webpack.ProvidePlugin({
			"React": "react",
		}),
		new CleanWebpackPlugin(pathsToClean),
		new HtmlWebpackPlugin({
			template: 'index.html',
		}),
		new webpack.HotModuleReplacementPlugin(),
	],
};	
